package mediaserver.dlnaserver;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.net.Inet4Address;

public class DLNAServer implements Runnable {

	@Override
	public void run() {
		try{
			DatagramPacket packet;
			
			InetAddress ssdpAddr;
			ssdpAddr = InetAddress.getByAddress( new byte[] { (byte)239, (byte)255, (byte)255, (byte)250}); 
			int ssdpPort = 1900; 
			
			
			String s = "NOTIFY * HTTP/1.1\r\n"; 
			s += "Host:239.255.255.250:1900\r\n";
			s += "NT:upnp:rootdevice\r\n";
			s += "NTS:ssdp:alive\r\n";
			s += "Location:http://10.0.0.100:2869/upnphost/udhisapi.dll?content=uuid:e711a4bf-5a90-43e1-bd01-e7d74c0d0706\r\n";
			s += "USN:uuid:e711a4bf-5a90-43e1-bd01-e7d74c0d0706::upnp:rootdevice\r\n";
			s += "Cache-Control:max-age=1800\r\n";
			s += "Server:Microsoft-Windows-NT/5.1 UPnP/1.0 UPnP-Device-Host/1.0\r\n";
			
			byte[] data = s.getBytes("US-ASCII"); 
			packet = new DatagramPacket( data, data.length, ssdpAddr, ssdpPort ); 
			DatagramSocket toSocket = new DatagramSocket(); 
			toSocket.send( packet );
			
			
			
		}catch(IOException e){
			
		}
	}

	
	
}
